        TITL DAI FIRMWARE 0EE09-0EFFF  V1.1
        ORG   :EE09
*
*
*
**********************************
* LIST EXPRESSION AFTER 'IF' (1) *
**********************************
*
* Lists '<expr> THEN <expr>'.
*
SCN21   CALL  SEXPS     List <expr>; print space
        CALL  STXTS     Print 'THEN'
MPT17   DBL   L0E350
        INX   B
        JMP   SCOM      List statement
*
* DATA :
*
L0E350  DATA  :04
        DATA  :54       T
        DATA  :48       H
        DATA  :45       E
        DATA  :4E       N
*
**********************************
* LIST EXPRESSION AFTER 'IF' (2) *
**********************************
*
* Lists '<expr> GOTO <linenr>'.
*
SCN22   CALL  SEXPS     List <expr>; print space
        CALL  STXTS     Print 'GOTO'
        DBL   SGOTO
        JMP   L0E318    List linenr
*
**********************************
* LIST EXPRESSION AFTER 'IF' (3) *
**********************************
*
* Lists '<expr> THEN <linenr>'.
*
SC22A   CALL  SEXPS     List <expr>; print space
        CALL  STXTS     Print 'THEN'
        DBL   L0E350
        JMP   L0E318    List linenr
*
*******************************
* LIST EXPRESSION AFTER 'FOR' *
*******************************
*
* Lists '<LET statement> TO <expr> (STEP <expr>)'.
*
SCN23   CALL  SCN20     List expr of LET statement
        CALL  SCHSP     Print space
        CALL  STXTS     Print 'TO'
        DBL   RLA20
        CALL  SCEXP     List <expr>
        LDAX  B         Get next byte
        INX   B
        CPI   :FF       Terminator?
        RZ              Then abort
        DCX   B         Else:
        CALL  STXSS     Print 'STEP'
        DBL   SSTEP
        JMP   SCEXP     List <expr>
*
* DATA:
*
RLA20   DATA  :02
        DATA  :54       T
        DATA  :4F       O
*
********************************
* LIST EXPRESSION AFTER 'NEXT' *
********************************
*
SCN24   JMP   L0E305    List var.ref.
*
**********************************
* LIST EXPRESSIONS AFTER 'PRINT' *
**********************************
*
SCN25   LDAX  B         Get nr of expr
        INX   B
        MOV   D,A       into D
S2510   DCR   D
        RM              Abort if ready
        INX   B
        CALL  SCEXP     List <expr>
        LDAX  B         Get next byte
        INX   B
        CPI   :FF       Terminator?
        RZ              Then abort
        CALL  OUTC      Else: print this byte
        JMP   S2510     List next expr
*
**********************************
* LIST EXPRESSION AFTER 'ON' (1) *
**********************************
*
* Lists '<expr> GOTO <linenrs>'.
*
SCN26   CALL  SEXPS     List <expr>; print space
        CALL  STXTS     Print 'GOTO'
        DBL   SGOTO
        JMP   S2710     List linenrs
*
**********************************
* LIST EXPRESSION AFTER 'ON' (2) *
**********************************
*
* Lists '<expr> GOSUB <linenrs>'.
*
SCN27   CALL  SEXPS     List <expr>; print space
        CALL  STXTS     Print 'GOSUB'
        DBL   SGOSUB
S2710   LDAX  B         Get nr of linenrs
        INX   B
        MOV   D,A       into D
S2720   CALL  L0E318    List linenr
        DCR   D
        RZ              Abort if ready
        CALL  SCHCO     Print ','
        JMP   S2720     List next linenr
*
*********************************
* LIST EXPRESSION AFTER 'CALLM' *
*********************************
*
SCN28   CALL  SCEXP     List <expr>
        JMP   S1210     Print ','; List next expr
*
*********************
* SET I/O DIRECTION *
*********************
*
* Part of RESET (C719). Only used for A = 0.
* Depending on A, the input switch #0296 and
* the output switch #0131 are set.
* Default DINC is RS232.
*
*            INSW:      OTSW:
*       A=0: keyboard   screen/RS232
*       A=1: DINC       screen
*       A=2: DINC       editbuffer
*       A=3: DINC       DOUTC
*
MPT02   STA   ENVPT     Select keyb or DINC
        STA   OTSW      Select screen/RS232/edit/
 REM DOUTC
        RET 
*
***************
* SET VOLUMES *
***************
*
* Part of RUN TALK (CD64).
*
* Entry: A: Parameter code.
*        HL: Pointer to volume byte.
*
RTK40   PUSH  H         Save pntr to volume
        MOV   L,M       Volume in L
        MVI   H,:0F
        RAR             Check parameter code
        JNC   RTK50     Jump if channel 0/2
*
* If channel 1/N:
*
        DAD   H
        DAD   H
        DAD   H
        JMP   MPT47     Continu
*
**********************
* LIST AN EXPRESSION *
**********************
*
* Entry: BC:   Points to expression in program.
*        (BC): 1.... Expr starts with operator.
*              01... Variable reference.
*              001.. Function call.
*              Else  Constant.
* Exit:  BC points after expression.
*        DE preserved, AFHL corrupted.
*
SCEXP   PUSH  D
        LDAX  B         Get opcode
        ORA   A
        JP    L0E301    If no starting operator
 REM
* If starting with operator:
 REM
        INX   B
        ANI   :1F       Only 5 bits of opcode
        CPI   :1A       '(' ?
        PUSH  PSW       Save opcode
        CC    SCEXP     List expr if binary
 REM operation
        LXI   H,SBRA    Addr table opcode strings
L0E300  MOV   D,H       ) in DE
        MOV   E,L       )
        CALL  DADM      HL points after table
        POP   PSW       Get opcode
        PUSH  PSW
        XRA   M         Comp it with table
        INX   H
        ANI   :1F
        JNZ   L0E300    Check next opcode if not
 REM found
        XCHG            If found: addr string in HL
        INX   H
        MOV   A,M       Get 1st char
        DCX   H         Pnts to length
        CALL  ALPHA     Check if upper case char
        PUSH  PSW
        CC    SCHSP     Print space if 1st char is
 REM a letter
        CALL  PSTR      Print string from table
        POP   PSW
        CC    SCHSP     Print space if 1st char was
 REM a letter
        CALL  SCEXP     List remaining operand
        POP   PSW       Get orig. opcode
        CPI   :1A       Was it '(' ?
        CZ    L0E310    Then print ')'
        POP   D
        RET 
 REM
* Not starting with operator:
 REM
L0E301  RLC 
        RLC 
        JC    L0E303    Jump if var.ref
        RLC 
        JC    L0E302    Jump if function call
 REM
* If constant:
 REM
        CALL  SCON      List constant
        POP   D
        RET 
 REM
* If function call:
 REM
L0E302  CALL  SFUN      List function reference
        POP   D
        RET 
 REM
* If variable reference:
 REM
L0E303  CALL  L0E305    List a var.reference
 REM (array with arguments)
        POP   D
        RET 
*
*****************************
* LIST A VARIABLE REFERENCE *
*****************************
*
* SCARN:  Entry for arrays without arguments (name
*         only).
* L0E305: Entry for arrays with arguments.
*
* Entry: BC points to variable reference in program.
*
SCARN   MVI   D,:BF     Set mask 'no arg'
        JMP   L0E306
*
L0E305  MVI   D,:FF     Set mask 'with arg'
L0E306  PUSH  D         Save mask
        LDAX  B         Get byte
        INX   B
        ANI   :3F       Skip bit 6,7
        MOV   D,A       Rest in D
        LDAX  B         Get next byte
        INX   B
        MOV   E,A       in E (Now DE is offset
 REM of start of symtab)
        LHLD  STBBGN    Get start symtab
        DAD   D         Add offset from start
        POP   D         Get mask
        PUSH  H         Save var.addr in symtab
        CALL  FNAME     Find name in symtab
        MOV   A,M       Get T/L byte
        ANA   D         AND with mask
        PUSH  PSW
        INX   H
        ANI   :0F       Get length
        MOV   E,M       Get 1st byte of name in E
        CALL  PSTRM     List name; addr in HL,
 REM length in A
        MVI   D,:00
        LXI   H,IMPBAS  Startaddr for IMPTAB
        DAD   D         Addr var.type in IMPTAB
        POP   PSW       Get mask
        PUSH  PSW
        ANI   :30       Bits 4,5 only
        CMP   M         Comp with IMPTAB
        JZ    L0E308    Jump if identical
        CPI   :00       FPT ?
        MVI   D,:21     Then D: '!'
        JZ    L0E307
        CPI   :10       INT ?
        MVI   D,:25     Then D: '%'
        JZ    L0E307
        MVI   D,:24     Else: D: '$'
L0E307  MOV   A,D
        CALL  OUTC      Print type sign
L0E308  POP   PSW       Get mask
        ANI   :40       Bit 6 only
        POP   H         Get addr of string
        RZ  
 REM
* Bit 6=1 (array with arguments):
 REM
        LDAX  B         Get nr of expressions
        INX   B
        MOV   D,A       in D
        CALL  SCHRI     Print '('
        DATA  :28
L0E309  INX   B
        PUSH  D
        CALL  SCEXP     List expression
        POP   D
        DCR   D         Ready ?
        CNZ   SCHCO     If not: print ','
        JNZ   L0E309    and list next expr
L0E310  CALL  SCHRI     If ready: Print ')'
        DATA  :29
        RET 
*
*****************************
* LIST A FUNCTION REFERENCE *
*****************************
*
* Finds functionname in table with startaddress
* #CFE6 and prints it. Eventual arguments are
* printed between brackets.
*
* Entry: BC points to function code (#20).
* Exit:  BC updated, AFEHL preserved, D=0.
*
SFUN    INX   B
        LDAX  B
        INX   B
        MOV   D,A
        LXI   H,SABS    Startaddr function table
L0E312  DCR   D
        JM    L0E313    If found
        CALL  DADD      Calc addr next string in tab
        JMP   L0E312    Test next function name
L0E313  CALL  PSTR      List function name
        MOV   A,M       Get byte after string
        ANI   :0F       Only nr of following args
        MOV   D,A       in D
        RZ              Abort if no arguments
        CALL  SCHRI     Print '('
        DATA  :28
L0E314  CALL  SCEXP     List expression
        DCR   D         Decr nr of arg
        CNZ   SCHCO     If <>0, print ','
        JNZ   L0E314    and list next expr
        JMP   L0E310    If ready: print ')'
*
*******************
* LIST A CONSTANT *
*******************
*
* The constant is decoded to ASCII, prettied and
* printed.
*
* Codes:   #10: FPT       #18: Quoted string
*          #14: INT       #19: Unquoted string
*          #15: HEX
*
* Entry: BC: Points to constant in program.
* Exit:  BC updated, DE preserved, AF corrupted.
*        HL: points after end of printed string.
*
SCON    LDAX  B         Get type of constant
        INX   B
        MOV   H,B       ) Addr constant in HL
        MOV   L,C       )
 REM
* If string:
 REM
        CPI   :18       Quoted string ?
        JZ    SQTS      Then list it
        CPI   :19       Unquoted string ?
        JZ    SUQTS     Then list it
 REM
* If number:
 REM
        RST   4         Copy constant value to MACC
        DATA  :0C
        CPI   :10       FPT ?
        JZ    SC020     Then list FPT value
        CPI   :14       INT ?
        PUSH  PSW
        CZ    SCINT     List INT value
        POP   PSW
        CNZ   SCHEX     Else: list HEX value
SC010   INX   B
        INX   B
        INX   B
        INX   B         BC points after constant
        RET 
SC020   CALL  SCFPT     List FPT value
        JMP   SC010
*
*********************
* LIST A LINENUMBER *
*********************
*
* Entry: BC: Points to linenumber.
* Exit:  BC updated, DE preserved, AFHL corrupted.
*
L0E318  LDAX  B         Get hibyte linenr
        INX   B
        MOV   H,A       in H
        LDAX  B         Get lobyte linenr
        INX   B
        MOV   L,A       in L
SLN10   CALL  FR2BY     Linenr into MACC
        MOV   A,H
        ORA   L         Linenr <>0 ?
        CNZ   SCINT     Then list linenr
        RET 
*
*************************************
* LIST A INT VALUE OF MACC CONTENTS *
*************************************
*
* The value is the contents of the MACC, prepared
* for output, and moved into the outputbuffer
* DECBUF (#00E3). A Leading space is omitted.
*
* Exit: BCDE preserved. A corrupted.
*       HL: Points after string in DECBUF.
*
SCINT   CALL  IBCP      Convert MACC for INT
 REM output into DECBUF
SSSPC   LHLD  DOBUF     Get addr DECBUF
        PUSH  D
        MOV   D,M       String length in D
        INX   H
        MOV   A,M       1st char in A
        CPI   :20       Space ?
        JNZ   SSS10     Jump if no leading space
        INX   H         ) Omit leading space
        DCR   D         )
SSS10   MOV   A,D       Get nr of char in A
        POP   D
        CALL  PSTRM     Print contents DECBUF
        RET 
*
***********************************
* LIST FPT VALUE OF CONTENTS MACC *
***********************************
*
* Exit: BCDE preserved. AF corrupted.
*       HL points after string in DECBUF.
*
SCFPT   CALL  FBCP      Convert MACC for FPT output
        JMP   SSSPC     List its contents
*
***********************************
* LIST HEX VALUE OF CONTENTS MACC *
***********************************
*
* Exit: BCDE preserved. AF corrupted.
*       HL points after string in DECBUF.
*
SCHEX   CALL  SCHRI     Print '#'
        DATA  :23
        JMP   PHEX      List in hex
*
************************
* LIST A QUOTED STRING *
************************
*
* Entry: BC: Points to string.
* Exit:  BC and HL point after string.
*        AF corrupted. DE preserved.
*
SQTS    CALL  SCHRI     Print "
        DATA  :22
        CALL  SUQTS     List string
        CALL  SCHRI     Print "
        DATA  :22
        RET 
*
************************
* LIST UNQUOTED STRING *
************************
*
* Entry: BC points to string.
* Exit:  BC and HL point after string.
*        AFDE preserved.
*
SUQTS   MOV   H,B       ) Stringaddr in HL
        MOV   L,C       )
        CALL  PSTR      List string
        MOV   B,H       )
        MOV   C,L       ) Addr after string in BC
        RET 
*
******************
* LIST CHARACTER *
******************
*
* Entry: On stack: The address of the character to
*                  be printed.
* Exit:  BCDEHL preserved. F corrupted.
*        A: Character printed.
*
SCHRI   XTHL            Get addr from stack
        MOV   A,M       Get char
        INX   H         HL pnts after char
        XTHL            Returnaddr on stack
        JMP   OUTC      List char.
*
********************************
* LIST EXPRESSION; PRINT SPACE *
********************************
*
SEXPS   JMP   LC230     List expr, print space
*
        DATA  :3E
*
*
*
        UNL
STXTS   EQU   :CE78
SCOM    EQU   :ECCC
SGOTO   EQU   :CBF9
SCN20   EQU   :EDFF
SCHSP   EQU   :CE6B
STXSS   EQU   :CE75
SSTEP   EQU   :CD3D
OUTC    EQU   :DD60
SGOSUB  EQU   :CC01
SCHCO   EQU   :CE70
S1210   EQU   :ED6E
ENVPT   EQU   :0296
OTSW    EQU   :0131
RTK50   EQU   :E67C
MPT47   EQU   :E67B
SBRA    EQU   :CF86
DADM    EQU   :DE39
ALPHA   EQU   :DE02
PSTR    EQU   :DB32
STBBGN  EQU   :02A1
FNAME   EQU   :CA95
PSTRM   EQU   :DB44
IMPBAS  EQU   :0234
SABS    EQU   :CFE6
DADD    EQU   :CAAE
FR2BY   EQU   :EB46
IBCP    EQU   :DB5F
DOBUF   EQU   :C033
FBCP    EQU   :CE9B
PHEX    EQU   :DB4A
LC230   EQU   :CE68
        LST
        END 
